<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/admincheck.asp"-->
<%if session("admin")="" then
response.Write "<script language='javascript'>alert('网络超时或您还没有登陆！');window.location.href='login.asp';</script>"
response.End
end if
%>
<!--#include file="inc/meta.asp"-->
<body>
<%if request.QueryString("action")="save" then%>
<!--#include file="inc/md5.asp"-->
<%
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from admin where admin='"&session("admin")&"'",conn,1,3
if md5(trim(request("password")))<>rs("password") then
response.Write "<script language=javascript>alert('原密码错误，请返回重新输入');history.go(-1);</script>"
response.End
else
rs("password")=md5(trim(request("password2")))
rs.Update
rs.Close
set rs=nothing
session("admin")=""
session("flag")=""
response.Write "<script language=javascript>alert('更改成功，请用新密码重新登陆！');history.go(-1);</script>"
end if
response.End
end if
%>
<div id="bodyright">
<table class="tableBorder" width="70%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<form name="renpassword" method="post" action="admin_pw.asp?action=save">
<tr> 
<td height="25" colspan="2" align="center" background="images/admin_bg_1.gif"><b><font color="#ffffff">更改管理密码</font></b></td>
</tr>
<tr bgcolor="#E8F1FF"> 
<td width="40%" height="20" align="right" bgcolor="#E8F1FF">管理 I D：</td>
<td width="60%" align="left" bgcolor="#E8F1FF">&nbsp;<font color=red><%=session("admin")%></font></td>
</tr>
<tr bgcolor="#E8F1FF"> 
<td height="20" align="right" bgcolor="#E8F1FF">原 密 码：</td>
<td align="left" bgcolor="#E8F1FF">&nbsp;
  <input name="password" type="password" id="password" size="16"></td>
</tr>
<tr bgcolor="#E8F1FF"> 
<td height="20" align="right" bgcolor="#E8F1FF">新 密 码：</td>
<td align="left" bgcolor="#E8F1FF">&nbsp;
  <input name="password1" type="password" id="password1" size="16"></td>
</tr>
<tr bgcolor="#E8F1FF"> 
<td height="20" align="right" bgcolor="#E8F1FF">确认密码：</td>
<td align="left" bgcolor="#E8F1FF">&nbsp;
  <input  name="password2" type="password" id="password2" size="16"></td>
</tr>
<tr bgcolor="#E8F1FF">
<td height="20" align="right" bgcolor="#E8F1FF"></td>
<td align="left" bgcolor="#E8F1FF">&nbsp;
  <input onClick="return check();" type="submit" class="formbutton" name="Submit" value="确定更改">
</td>
</tr>
</form>
</table>
</div>
<!--#include file="copyright.asp"-->
</body>
<%call CloseConn()%>
</html>
<script LANGUAGE="javascript">
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
function check()
{
  if(checkspace(document.renpassword.password.value)) {
	document.renpassword.password.focus();
    alert("原密码不能为空！");
	return false;
  }
  if(checkspace(document.renpassword.password1.value)) {
	document.renpassword.password1.focus();
    alert("新密码不能为空！");
	return false;
  }
    if(checkspace(document.renpassword.password2.value)) {
	document.renpassword.password2.focus();
    alert("确认密码不能为空！");
	return false;
  }
    if(document.renpassword.password1.value != document.renpassword.password2.value) {
	document.renpassword.password1.focus();
	document.renpassword.password1.value = '';
	document.renpassword.password2.value = '';
    alert("新密码和确认密码不相同，请重新输入");
	return false;
  }
	document.admininfo.submit();
  }
</script> 